package org.balabala.user.controller;

import java.util.Arrays;
import java.util.Map;


import org.balabala.user.entity.ContributeEntity;
import org.balabala.user.service.ContributeService;
import org.balabala.user.utils.PageUtils;
import org.balabala.user.utils.Resp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;





/**
 * 
 * 发布
 * @author hanshanxi
 * @email 3176988793@qq.com
 * @date 2021-09-04 09:31:52
 */
@RestController
@RequestMapping("user/contribute")
public class ContributeController {
    @Autowired
    private ContributeService contributeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public Resp list(@RequestParam Map<String, Object> params){
        PageUtils page = contributeService.queryPage(params);

        return Resp.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{contributionId}")

    public Resp info(@PathVariable("contributionId") Integer contributionId){
		ContributeEntity contribute = contributeService.getById(contributionId);

        return Resp.ok().put("contribute", contribute);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")

    public Resp save(@RequestBody ContributeEntity contribute){
		contributeService.save(contribute);
        return Resp.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")

    public Resp update(@RequestBody ContributeEntity contribute){
		contributeService.updateById(contribute);

        return Resp.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")

    public Resp delete(@RequestBody Integer[] contributionIds){
		contributeService.removeByIds(Arrays.asList(contributionIds));

        return Resp.ok();
    }

}
